/**
 * Created by ljf on 2018/4/19.
 * FlatList 空视图
 */
import React, {Component} from 'react';
import {Image, StyleSheet, Text,} from 'react-native';
import {View,Button} from 'react-native-ui-lib';
import PropTypes from "prop-types";
import {commonStyles} from "../../configs/commonStyle";


export default class ListEmpty extends Component {

    static propTypes = {
        desc: PropTypes.string,
        img:PropTypes.element,
        showEmpty:PropTypes.bool,
        btnStr:PropTypes.string,
    }
    static defaultProps = {
        desc: null,
        showEmpty:true,
        btnStr:null,
        img:<Image style={{width: 120, height: 120}} source={require('../../images/programing.png')}/>
    }

    constructor(props) {
        super(props);
    }

    render() {
        const {btnStr,callBack,desc}=this.props;
        if(this.props.showEmpty)
        return (
                <View style={styles.body}>
                    {this.props.img}
                    {desc&&<Text style={styles.descText}>{desc}</Text>}
                    {btnStr&&(<Button label={btnStr} size={'xSmall'} onPress={()=>callBack()} bg-primary />)}
                </View>
        );
        return null;
    }
}

const styles = StyleSheet.create(
    {
        body:{flex: 1, justifyContent: 'center', alignItems: 'center',paddingVertical:10},
        descText:{fontSize:14,color:'#999999',marginTop:10},
        btn:{backgroundColor:'#FF5C25',borderRadius:8,paddingVertical:8,paddingHorizontal:25,marginTop:40},
    });


